import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import screens from './src/screens';

const Stack = createNativeStackNavigator();

const App = () => {
  return (
    <SafeAreaProvider>
      <NavigationContainer>
        <Stack.Navigator initialRouteName="TabbarPage">
          {Object.entries(screens).map(([name, screen]) => {
            if (typeof screen === 'function') {
              return (
                <Stack.Screen key={name} name={name} component={screen} />
              );
            } else {
              return (
                <Stack.Screen
                  key={name}
                  name={name}
                  component={screen.component}
                  options={screen.options}
                />
              );
            }
          })}
        </Stack.Navigator>
      </NavigationContainer>
    </SafeAreaProvider>
  );
};

export default App;